<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;
use app\model\SysMenu;

Route::get('think', function () {
    return 'Hello,ThinkPHP6!--test';
});

Route::get('index', 'index/index');
Route::get('about', 'index/about');
Route::get('development', 'index/development');
Route::get('honor', 'index/honor');
Route::get('factory', 'index/factory');
Route::get('contactus', 'index/contactus');
Route::get('wire/:type', 'product/wirelist')->pattern(['type' => '\d+']);
Route::get('wire', 'product/wire');
Route::get('surface/list', 'product/surfacelist');
Route::get('surface', 'product/surface');
Route::get('wear_plate', 'product/wearPlate');
Route::get('alloy_powders', 'product/alloy_powders');
Route::get('alloy_powders/list', 'product/alloy_powders_list');
Route::get('industry/single/:id', 'industry/single')->pattern(['id' => '\d+']); // 单页测试
Route::get('industry/:id', 'industry/read')->pattern(['id' => '\d+']);
Route::get('industry', 'industry/index');
Route::get('news/<year>-<month>-<day>/:id', 'article/read');
Route::get('news', 'article/index');
Route::get('search', 'index/search');

Route::group('en', function () {
    Route::get('contactus', 'en.index/contactus');
    Route::get('about', 'en.index/about');
    Route::get('development', 'en.index/development');
    Route::get('honor', 'en.index/honor');
    Route::get('factory', 'en.index/factory');
    Route::get('contactus', 'en.index/contactus');
    Route::get('news/<year>-<month>-<day>/:id', 'en.article/read');
    Route::get('news', 'en.article/index');
    Route::get('wire/:type', 'en.product/wirelist')->pattern(['type' => '\d+']);
    Route::get('wire', 'en.product/wire');
    Route::get('surface/list', 'en.product/surfacelist');
    Route::get('surface', 'en.product/surface');
    Route::get('wear_plate', 'en.product/wearPlate');
    Route::get('alloy_powders/list', 'en.product/alloy_powders_list');
    Route::get('alloy_powders', 'en.product/alloy_powders');
    Route::get('industry/single/:id', 'en.industry/single')->pattern(['id' => '\d+']); // 单页测试
    Route::get('industry/:id', 'en.industry/read')->pattern(['id' => '\d+']);
    Route::get('industry', 'en.industry/index');
    Route::get('search', 'en.index/search');
});
Route::get('en', 'en.index/index');

// Route::group('v0', function () {
//     Route::get('about', 'v0.index/about');
//     Route::get('contactus', 'v0.index/contactus');
//     Route::get('wire', 'v0.index/wire');
//     Route::get('surface', 'v0.index/surface');
//     Route::get('wear_plate', 'v0.index/wearPlate');
//     Route::get('industry/:id', 'v0.industry/read');
//     Route::get('industry', 'v0.industry/index');
//     Route::get('test', 'v0.index/test');

//     Route::get('news', 'v0.article/index')->append(['cid'=>14]);
//     Route::get('study', 'v0.article/index')->append(['cid'=>15]);
//     Route::get('/tags/:name', 'v0.index/article/tags');
//     Route::get('/<year>-<month>-<day>/:id', 'v0.article/read');
//     Route::get('/:year/:month', 'v0.index/article/archive')->pattern(['year' => '\d+', 'month'   => '\d+']);
// });

// Route::group('v1', function () {
//     Route::get('index', 'v1.index/index');
//     Route::get('about', 'v1.index/about');
//     Route::get('development', 'v1.index/development');
//     Route::get('honor', 'v1.index/honor');
//     Route::get('factory', 'v1.index/factory');
//     Route::get('contactus', 'v1.index/contactus');
//     Route::get('wire/:type', 'v1.product/wirelist')->pattern(['type'=>'\d+']);
//     Route::get('wire', 'v1.product/wire');
//     Route::get('surface/list', 'v1.product/surfacelist');
//     Route::get('surface', 'v1.product/surface');
//     Route::get('wear_plate', 'v1.product/wearPlate');
//     Route::get('industry/:id', 'v1.industry/read')->pattern(['id'=>'\d+']);
//     Route::get('industry', 'v1.industry/index');
//     Route::get('news/<year>-<month>-<day>/:id', 'v1.article/read');
//     Route::get('news', 'v1.article/index');
//     Route::get('search', 'v1.index/search');
// });

Route::get('token', 'index/token');
Route::post('message_board', 'index/saveGuestBook');

Route::get('sys/index', 'sys.index/index');
Route::post('/sys/index/usedspace', 'sys.index/usedspace');
Route::post('/sys/index/clearcache', 'sys.index/clearcache');
Route::post('/sys/index/countArticle', 'sys.index/countArticle');
Route::post('/sys/index/countIndustry', 'sys.index/countIndustry');
Route::post('/sys/index/countGuestBook', 'sys.index/countGuestBook');
Route::post('/sys/index/saveIndexButton', 'sys.index/saveIndexButton');
Route::get('sys/login/index', 'sys.login/index');
Route::post('sys/login/dologin', 'sys.login/dologin');
Route::get('sys/login/logout', 'sys.login/logout');
Route::get('sys/verify', 'sys.login/verify');
Route::post('sys/file_manager/uploadImage', 'sys.file_manager/uploadImage');
Route::post('sys/file_manager/uploadMoive', 'sys.file_manager/uploadMoive');
Route::post('sys/file_manager/ckeditorUploadImage', 'sys.file_manager/ckeditorUploadImage');
Route::post('sys/file_manager/uploadUrlImg', 'sys.file_manager/uploadUrlImg');

Route::group('sys', function () {
    $menuList = SysMenu::where('type', '<>', '0')->field('menuid, pid, name, url, icon')->select();
    foreach ($menuList as $menu) {
        $menuUrl = $menu->url;
        $router = 'sys.' . $menuUrl;
        Route::rule($menuUrl, $router);
    }
});

Route::get('sys', 'sys.index/index');
